import java.util.Stack;

/**
 * Created by smartown on 2017/5/16.
 * <p>
 * Stack(栈)是Vector的一个子类，它实现了一个标准的后进先出的栈。
 */
public class StackTest {
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        try {
            System.out.println("stack:" + stack);
            showPush(stack, 11);
            showPush(stack, 12);
            showPush(stack, 13);
            showPop(stack);
            showPop(stack);
            showPop(stack);
            showPop(stack);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void showPush(Stack<Integer> stack, int i) {
        stack.push(i);
        System.out.println("push(" + i + ")");
        System.out.println("stack:" + stack);
    }

    public static void showPop(Stack<Integer> stack) {
        Integer a = stack.pop();
        System.out.println("pop -> " + a);
        System.out.println("stack:" + stack);
    }

}
